/*
 * Copyright Thoughtworks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@import "../../global/common";

$c-dropdown-height: 34px;
$c-dropdown-border-color: #d6e0e2;
$c-dropdown-text-color: #000;
$c-dropdown-bg-hover: rgb(0, 0, 0, 20%);
$c-dropdown-open-z-index: 5;
$c-dropdown-head-z-index: 2;
$c-dropdown-arrow-z-index: 6;
$c-dropdown-background: #fff;

.groupby {
  display: flex;
  align-items: center;
}

.grouping-label {
  white-space: nowrap;
  margin: 0 10px 0 0;
  display: inline-block;
}

%dropdownwidth {
  min-width: 150px;
  display: inherit;
}

.c-dropdown {
  @extend %dropdownwidth;

  position: relative;
  font-size: 13px;

  &.open {
    z-index: $c-dropdown-open-z-index;

    .c-dropdown-body {
      display: block;
    }
  }
}

.c-dropdown-head {
  display: inline-block;
  position: relative;
  z-index: $c-dropdown-head-z-index;
  height: $c-dropdown-height;
  line-height: 32px;
  padding: 0 20px 0 15px;
  border: 1px solid $c-dropdown-border-color;
  border-radius: 3px;
  background: $c-dropdown-background;
  width: 100%;
  cursor: pointer;
  font-weight: 600;
  color: $c-dropdown-text-color;

  .open & {
    border-radius: 3px 3px 0 0;
  }

  &:hover,
  &:active,
  &:focus,
  &:visited {
    color: $c-dropdown-text-color;
    outline: none;
  }
}

.c-dropdown-body {
  @extend %dropdownwidth;

  position: absolute;
  border-radius: 0 0 3px 3px;
  background: $c-dropdown-background;
  top: $c-dropdown-height;
  display: none;
  border: 1px solid $c-dropdown-border-color;
  border-top: none;
  color: $c-dropdown-text-color;
}

.c-dropdown-item {
  text-decoration: none;
  display: block;
  padding: 7px 20px;
  cursor: default;
  color: $c-dropdown-text-color;

  &:first-child {
    border: none;
  }

  &:hover {
    color: $c-dropdown-text-color;
    background: $c-dropdown-bg-hover;
  }
}

.c-down-arrow {
  position: absolute;
  right: 9px;
  top: 5px;
  cursor: pointer;
  z-index: $c-dropdown-arrow-z-index;
  font-size: 15px;

  @include icon-before($type: $fa-var-angle-down);
}
